CLIENT = tp2_client
SERVER = tp2_server
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.

SOURCES_CLNT.c = 
SOURCES_CLNT.h = 
SOURCES_SVC.c = 
SOURCES_SVC.h = 
SOURCES.x = tp2.x

TARGETS_SVC.c = tp2_svc.c tp2_server.c
TARGETS_CLNT.c = tp2_clnt.c tp2_client.c
TARGETS = tp2.h tp2_clnt.c tp2_svc.c tp2_client.c tp2_server.c

OBJECTS_CLNT = $(SOURCES_CLNT.c:%.c=%.o) $(TARGETS_CLNT.c:%.c=%.o)
OBJECTS_SVC = $(SOURCES_SVC.c:%.c=%.o) $(TARGETS_SVC.c:%.c=%.o)
# Compiler flags

CFLAGS += -Wall -g `mysql_config --cflags --libs`
LDLIBS += -L. -lpthread
RPCGENFLAGS = -K -1 -M

# Targets
all : $(CLIENT) $(SERVER)

$(TARGETS) : $(SOURCES.x)
#	rpcgen $(RPCGENFLAGS) $(SOURCES.x)

$(OBJECTS_CLNT) : $(SOURCES_CLNT.c) $(SOURCES_CLNT.h) $(TARGETS_CLNT.c)

$(OBJECTS_SVC) : $(SOURCES_SVC.c) $(SOURCES_SVC.h) $(TARGETS_SVC.c)

$(CLIENT) : $(OBJECTS_CLNT)
	$(LINK.c) -o $(CLIENT) $(OBJECTS_CLNT) $(LDLIBS)

$(SERVER) : $(OBJECTS_SVC)
	$(LINK.c) -o $(SERVER) $(OBJECTS_SVC) $(LDLIBS)

